<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<script type="text/javascript" src="${path }/resources/js/jquery-1.7.2.min.js"></script>
<!-- ZUI 标准版压缩后的 JavaScript 文件 -->
<script src="${path }/resources/zui-1.6.0/js/zui.min.js"></script>
<script src="${path }/resources/zui-1.6.0/lib/datetimepicker/datetimepicker.min.js"></script>
<script src="${path }/resources/zui-1.6.0/lib/chosen/chosen.min.js"></script>
<!-- layer js -->
<script src="${path }/resources/layer/layer.js"></script>
<!-- 分页引入 -->
<script src="${path }/resources/pagination/jquery.pagination.js"></script>
<script>
//用户信息展示
function userInfo() {
	layer.open({
		type: 2,
		title: '信息查看',
		shadeClose: true,
		area: ['60%', '80%'],
		shade: 0.8,
		maxmin: true, //开启最大化最小化按钮
		content: ['${path}/myInfo', 'no'],
		end: function() {
		}
	});
}
//用户退出
function logOut() {
	layer.confirm('确定要退出系统吗？', {
		btn: ['嗯, 退出', '我再想想']
	}, function(index) {
		var url = '${path}/userLogOut';
		$.get(url, {}, function(data) {
			window.location.href = '${path}';
		}, 'json');
	});
}
$(function() {
	$('.resetBtn').click(function() {
		$('.form-control').val('');
		return false;
	});
	
	$('input').on('focus', function() {
	});
})

//添加表单验证
var getSubmitFlag = function($parentNode) {
	var inputs = $parentNode.find("input");
	var insWithRules = [];
	for (var i = 0; i < inputs.length; i++) {
		var tmpInput = $(inputs[i]).attr("data-validate");
		if (!tmpInput){} else {
			insWithRules.push(inputs[i]);
		}
	}
	var submitArr = [];
	for (var j = 0; j < insWithRules.length; j++) {
		var tmpFlag = validateInput(insWithRules[j]);
		submitArr[j] = tmpFlag;
	}
	var flag = true;
	for (var i = 0; i < submitArr.length; i++) {
		if (submitArr[i] == false) {
			flag = false;
		}
	}
	return flag;
}
//单个表单验证

var validateInput = function(element) {
	var tmpLiandegnjiFlag = true;
	var val = $(element).val();
	if(val && val.length > 255){
		layer.tips("111", $(element));
		return false;
	}
	var rule = $(element).attr("data-validate");
	if (rule) {
		var rs = rule.split("|");
		for (var i = 0; i < rs.length; i++) {
			if (rs[i] == 'required') {
				if (!$(element).val()) {
					$(element).css({"border-color": "red", "background-color": "#FFDBF7"});
					layer.tips("不能为空", $(element));
					tmpLiandegnjiFlag = false;
				} else {
					$(element).css({"border-color": "", "background-color": ""});
					tmpLiandegnjiFlag = true;
				}
			} else if (rs[i] == 'idCard') {
				var idCardReg = /^\d{15}(\d{2}[A-Za-z0-9])?$/;
				if (!idCardReg.test($(element).val())) {
					$(element).css({"border-color": "red", "background-color": "#FFDBF7"});
					layer.tips("11", $(element));
					tmpLiandegnjiFlag = false;
				} else {
					$(element).css({"border-color": "", "background-color": ""});
					tmpLiandegnjiFlag = true;
				}
			} else if (rs[i] == 'telphone') {
				var telReg = /^1[0-9]{10}$/;
				if (!telReg.test($(element).val())) {
					$(element).css({"border-color": "red", "background-color": "#FFDBF7"});
					layer.tips("请填写正确的电话号码", $(element));
					tmpLiandegnjiFlag = false;
				} else {
					$(element).css({"border-color": "", "background-color": ""});
					tmpLiandegnjiFlag = true;
				}
			}
		}
	}
	return tmpLiandegnjiFlag;
}

</script>
